﻿using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XinjeMesProgram.Entities.Maintenance
{
    public class RepairCatalogRequestModel
    {
        public string id { get; set; }

        public RepairCatalogModel data { get; set; }

        public RepairCatalogRequestModel() 
        {
            data = new RepairCatalogModel();
        }
    }

    public class RepairLogModel
    {
        public string id { get; set; }
        public string? data { get; set; }
        public IFormFile? picAddress { get; set; }
    }

    public class ProblemGradeAModel
    {
        //public string? grade { get; set; }

        public string? data { get; set; }
    }


    public class RepairCatalogFileModel
    {
        //public List<FileStream>? picAddress { get; set; }
        public string? detailchoose { get; set; }
        public string? product_category { get; set; }
        public List<string>? casValue { get; set; }
        public List<MyListItem>? list { get; set; }

        public string GetValueByKey(string? key)
        {
            var item = list.FirstOrDefault(x => x.key == key);
            if (item != null)
            {
                return item.value;
            }
            return string.Empty;
        }

    }


    public class RepairCatalogModel
    {
        public List<string>? picAddress { get; set; }
        public string? detailchoose { get; set; }
        public string? product_category { get; set; }
        public List<string>? casValue { get; set; }
        public List<MyListItem>? list { get; set; }

        public string GetValueByKey(string? key)
        {
            var item = list.FirstOrDefault(x => x.key == key);
            if (item != null)
            {
                return item.value;
            }
            return string.Empty;
        }

    }
    public class MyListItem
    {
        public MyListItem() 
        { 
            this.title = string.Empty;
            this.value = string.Empty;
            this.key = string.Empty;
        }
        public string? title { get; set; }
        public string? key { get; set; }
        public string? value { get; set; }
    }

}
